<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:59:"C:\wamp200\www\xgwnew/application/index\view\cart\qiye.html";i:1544429206;s:61:"C:\wamp200\www\xgwnew/application/index\view\public\base.html";i:1537861369;}*/ ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<title><?php echo $title; ?></title>
<link rel="stylesheet" href="__PUBLIC__/xsd/css/mui.min.css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/xsd/css/icons-extra.css" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/xsd/css/app.css?v1111121" />

</head>
<!--/head-->
<body>
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js" charset="utf-8"></script>
    <script type="text/javascript" src="https://apis.map.qq.com/tools/geolocation/min?key=QQ6BZ-24HC6-ZAXSZ-MTZAU-5MU2J-HEFEH&referer=鲜果屋"></script>
<script>
//alert("cc");
		  var geolocation = new qq.maps.Geolocation();
     var options = {timeout: 9000};
        var positionNum = 0;
	geolocation.getLocation(showPosition, showErr, options);
	
	function showPosition(position) {
		
            positionNum ++;
            document.getElementById("demo").innerHTML += "序号：" + positionNum;
            document.getElementById("demo").appendChild(document.createElement('pre')).innerHTML = JSON.stringify(position, null, 4);
            document.getElementById("pos-area").scrollTop = document.getElementById("pos-area").scrollHeight;
        };
 
        function showErr() {
            positionNum ++;
            document.getElementById("demo").innerHTML += "序号：" + positionNum;
            document.getElementById("demo").appendChild(document.createElement('p')).innerHTML = "定位失败！";
            document.getElementById("pos-area").scrollTop = document.getElementById("pos-area").scrollHeight;
        };

	
</script>

	<!--/header-->

<style>
    .mui-row.mui-fullscreen>[class*="mui-col-"] {
        height: 100%;
    }

    .mui-col-xs-3,
    .mui-col-xs-9 {
        overflow-y: auto;
        height: 100%;
    }

    .mui-segmented-control .mui-control-item {
        line-height: 50px;
        width: 100%;
    }

    .mui-control-content {
        display: block;
    }

    .mui-segmented-control.mui-segmented-control-inverted .mui-control-item.mui-active {
        background-color: #fff;
    }
    .mui-toast-container {
        bottom: 50%;
        z-index: 999999999999999999;
    }
    .mui-btn-block{
      padding: 5px;
      border: 1px solid #ccc !important;
      margin: 5px;
      -webkit-appearance: none;
    }
    .active .mui-icon{
      display: block !important;
    }
    .submitbuttonqx {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 2.876712rem;
        background-color: red;
        color: #fff;
        text-align: center;
        text-decoration: none;
        font-size: 0.410959rem;
        font-weight: bold;
        line-height: 1.315068rem;
    }
</style>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/xsd/css/checkout.css" />
<header class="mui-bar mui-bar-nav" style="z-index:7">
			<a class="mui-icon mui-icon-left-nav mui-pull-left" href="<?php echo url('index/index/qiye', ['cid'=>$cid ]); ?>" ></a>
			<h1 class="mui-title">确定订单:</h1>
</header>
<div class="mui-content" style="    margin-bottom:60px;">

  <section class="cart-address" >
    <?php if(empty($qiyeUserinfo) || ($qiyeUserinfo instanceof \think\Collection && $qiyeUserinfo->isEmpty())): ?>
    <div class="address-item" onclick='window.location.href = "<?php echo url('index/address/addqiye', ['cid'=>$cid ]); ?>"' > 请添加一个用户信息 <span class="mui-icon mui-icon-arrowright"></span> </div><input type="hidden" value="11" id="testid" />
    <?php else: ?>
    <div class="address-item"   onclick='window.location.href =  "<?php echo url('index/address/qiyeindex', ['cid'=>$cid ]); ?>"'   >
        <h2 class="address-name" > <b ><?php echo $qiyeUserinfo['username']; ?></b>  <span ><?php echo $qiyeUserinfo['phone']; ?></span> </h2>
        <span class="mui-icon mui-icon-arrowright"></span>  </div>
    <?php endif; ?>


  </section>


  <section class="cart-group checkout-section">
    <h4 style="padding: .2rem .4rem;color: #666;    margin-bottom: 0;">商品列表</h4>
    <ul class="foodlist" style="    margin: 0;">
        <?php if(is_array($cartinfo['list']) || $cartinfo['list'] instanceof \think\Collection): $i = 0; $__LIST__ = $cartinfo['list'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
          <li> <span class="cellname"><?php echo $vo['good_name']; ?></span> <span class="cellquantity">x&nbsp;<?php echo $vo['num']; ?></span> <span class="celltotal">¥<?php echo $vo['num']*$vo['good_price']; ?></span> </li>
        <?php endforeach; endif; else: echo "" ;endif; ?>
    </ul>

    <div class="total">
        <div> <span>总计 <span id="zj" style="color:red">¥<?php echo $cartCountprice; ?></span>
          <?php if($companyInfo['is_wxpay'] == '1'): ?>
            余额 ¥<?php echo \think\Request::instance()->session('user.balance'); ?></span> &nbsp;&nbsp;
          <?php endif; ?>
         </div>
<span>实付<span style="color:red;" id="sf" data-sf="<?php echo $cartCountprice+$address['freight']-\think\Request::instance()->session('user.balance'); ?>"> ¥<?php echo $cartCountprice+$address['freight']-\think\Request::instance()->session('user.balance'); ?></span></span>
      </div>
  </section>
  <section class="checkout-section">
    <div class="cart-item fee" id="pstime" style="    margin: 0;" >
      <span>配送时间</span>
       <span class="cartitem-right" id="pssj">
         <i style="    font-style: normal;">
              <?php echo $companyInfo['delivery_dec']; ?>
         </i>
       </span>
    </div>
    <div class="cart-item fee" id="payment" style="    margin: 0;">
      <span>支付方式</span>
      <span class="cartitem-right">
        <i id="paywaytext" style="    font-style: normal;">
        <?php if($companyInfo['is_wxpay'] == '1'): ?>
          微信支付
        <?php else: ?>
          货到付款
        <?php endif; ?>

        </i>
        <span class="mui-icon mui-icon-arrowright"></span>
      </span>
    </div>
    <!-- <aside class="paylist ">
        <header class="paylist-header">支付方式</header>

        <?php if($companyInfo['is_wxpay'] == '1'): ?>
          <div class="paylist-item  <?php if(\think\Cookie::get('pay') == '1'): ?>active<?php endif; ?>" data-payway='1' ><span> 微信支付  </span> <span class="mui-icon mui-icon-checkmarkempty" style="color:#007aff;border: 1px solid;display:none"></span></div>
        <?php endif; ?>
        <div class="paylist-item  <?php if(\think\Cookie::get('pay') == '2'): ?>active<?php endif; ?>" data-payway='2' ><span> 货到付款  </span> <span class="mui-icon mui-icon-checkmarkempty" style="color:#007aff;border: 1px solid;display:none"></span></div>
    </aside>
    <div class="mask "></div> -->
    <?php if($companyInfo['is_wxpay'] == '1'): ?>
      <a class="cart-item fee"  id="coupon-item" style="    margin: 0;"> <span>优惠券</span>
        <span class="cartitem-right">
          <i style="    font-style: normal;">
            <?php if(empty(\think\Cookie::get('couponlist_id')) || (\think\Cookie::get('couponlist_id') instanceof \think\Collection && \think\Cookie::get('couponlist_id')->isEmpty())): ?>
              请选择优惠券
            <?php else: ?>
              <?php echo get_table_field(\think\Cookie::get('couponlist_id'),"id","price","CouponList"); ?>元优惠券
            <?php endif; ?>
          </i>
          <span class="mui-icon mui-icon-arrowright"></span>
        </span>
      </a>
    <?php endif; ?>
  </section>


  <form  method="post"  action="<?php echo url('order/qiye', ['cid'=>$cid ]); ?>">
    <section class="checkout-section">
    <div class="mui-input-row" style="margin: 10px 5px;">
      <textarea id="textarea" name="remark" rows="5" placeholder="备注"></textarea>
    </div>
    </section>
    <input type="hidden" name="index_type" value="1"  />
    <input type="hidden" name="is_tg" value="1"  />
    <input type="hidden" name="group_time" value="<?php echo config('grouptime'); ?>"  />
  </form>

  <script id="tpl2" type="text/html">
        <div class="select-time-box">
          <style>.wd50{width:50%!important;}</style>
          
          {{if date1}}

            <dl class="wd50"  id="jtdd"> <dt>{{date1}}<span>{{name1}}</span></dt>
                {{each list as value i}}
                  <dd class="allow"   data-start="{{value.start_time}}"  data-text="{{date1}}{{value.start_time}}-{{value.end_time}}送达" data-val="{{date1}},{{value.start_time}}-{{value.end_time}}">
                  	 <label for="radio-choice-0">{{value.start_time}}-{{value.end_time}}</label> </dd>
                {{/each}}
            </dl>
            {{else}}
              <style>.wd50{width:100%!important;}</style>
            {{/if}}
           

 
            <dl  class="wd50"> <dt>{{date2}}<span>{{name2}}</span></dt>
            	 {{if type2==2}}

            	<dd class="allow" data-text="{{date2}}10:00-13:00送达" data-val="{{date2}},10:00-13:00">
                  	<label for="radio-choice-0">10:30-13:00</label> </dd>
                  	{{/if}}
                {{each list as value i}}
                  <dd class="allow" data-text="{{date2}}{{value.start_time}}-{{value.end_time}}送达" data-val="{{date2}},{{value.start_time}}-{{value.end_time}}">
                  	<label for="radio-choice-0">{{value.start_time}}-{{value.end_time}} </label> </dd>
                {{/each}}
            </dl>
            
        </div>
  </script>


  <div class="select-time-mask" onclick="hideDeliveryTime()" style="display: none;"></div>
  <div class="select-time-wrap" id="select-model-01" style="display: none;"></div>

  <nav class="mui-bar mui-bar-tab" style="   border-bottom: none;  background-color: #3d3d3f; ">
      <span style="    color: #fff;font-size: .48rem;line-height: 1.273333rem;padding-left: .266667rem;">待支付 <span id="dzf" style="color:red"></span></span>
      <a href="javascript:" class="submitbutton" style="right: 2.876712rem;" >确定下单</a>
      <a  class="submitbuttonqx qxdd" data-url="<?php echo url('index/qiye', ['cid'=>$cid ]); ?>" >取消订单</a>
  </nav>
</div>




<!--/#footer-->

<script src="__PUBLIC__/js/jquery.js"></script>
<script src="__PUBLIC__/xsd/js/mui.min.js"></script>
<script src="__PUBLIC__/xsd/js/flexible.js"></script>
<script src="__PUBLIC__/xsd/js/template.js"></script>

<script type="text/javascript">
  $(function(){
    $('.submitbutton').on('tap', function(){        	if($("#testid").val()==11){    		   mui.toast('请添加用户！');        return;    	}
      $('form').submit();
    })

    $('#coupon-item').on('tap', function(){
        window.location.href = "<?php echo url('index/coupon/index'); ?>"
    })

    var is_wxpay = "<?php echo $companyInfo['is_wxpay']; ?>"

    if(is_wxpay  == 1){
      changeprice(is_wxpay)
    }



    $('.qxdd').on('tap', function(){
     var url = $(this).attr('data-url')
     var btnArray = ['否', '是'];
     mui.confirm('您确定要删除该订单吗？', '删除订单', btnArray, function(e) {
       if (e.index == 1) {
           $.post("<?php echo url('index/cart/clear'); ?>", {}, function(data) {
               mui.toast('删除成功！')
               setTimeout(function() {
                 window.location.href= url
               }, 2000);
           }, "json");

       } else {
         return ;
       }
     })

    })

    // $('#pstime').on('tap', function(){
    //           $(".select-time-mask").show(), $(".select-time-wrap").show();
    //
    // })
    $(document).on('tap', '.select-time-box dd.allow',function(){
      var $this = $(this),text = $this.attr('data-text'),val = $this.attr('data-val')
        $('#pssj i').text(text)
        $('#pssj input').val(val)
        $(".select-time-wrap").hide(), $(".select-time-mask").hide()

        $.getJSON("<?php echo url('index/cart/changecookie'); ?>", {name: 'deliverytime', 'val': val}, function(json, textStatus) {
   		 });
    })

    $('#payment').on('tap', function(){
        $('.paylist').addClass('open');
        $('.paylist').next().addClass('open');
    })

    $('.mask').on('tap', function(){
      $(this).removeClass('open')
      $('.paylist').removeClass('open')
    })
    $('.paylist-item').on('tap', function(){
      var val = $(this).text(),payway = $(this).attr('data-payway')
      $('#paywaytext').text(val)
      $('.paylist').next().removeClass('open')
      $('.paylist').removeClass('open')
      $(this).addClass('active').siblings().removeClass('active')
      $.getJSON("<?php echo url('index/cart/changecookie'); ?>", {name: 'pay', 'val': payway}, function(json, textStatus) {});
    })

  })

  function hideDeliveryTime() {
      $(".select-time-mask").hide(), $(".select-time-wrap").hide()
  }
  showDeliveryTime()
function showDeliveryTime() {
    var data = {}
        data.jt = new Date(),
        data.jm = data.jt.getMonth()+1,
        data.jd = data.jt.getDate();
        data.rq = data.jm+'-'+data.jd;

    $.post("<?php echo url('index/index/getDeliveryTime'); ?>", function(da) {
        if(da){
          data.list = da;

             data.name1 = ""

            data.date1 = ''

        }

        data.list = [{id: 10, start_time: "明天", end_time: "18:00", limit_num: 10, type: 0},{id: 11, start_time: "后天", end_time: "22:00", limit_num: 10, type: 0}]
          // data.name2 = "<?php echo config('grouptime'); ?> 配送"
          var html = template('tpl2', data);
          $('.select-time-wrap').html(html);



    }, "json");

}

function changeprice(way_id){
  if(way_id==1){
    $('.fbt').text("-¥<?php echo $subsidy; ?>")
    $('#freight').text("¥<?php echo (isset($address['freight']) && ($address['freight'] !== '')?$address['freight']:'0'); ?>")
    $('#zj').text("¥<?php echo $cartCountprice+$address['freight']; ?>");
    $('#sf').text("¥<?php echo $cartCountprice+$address['freight']-\think\Request::instance()->session('user.balance'); ?>");
    preferential("<?php echo $cartCountprice+$address['freight']-\think\Request::instance()->session('user.balance'); ?>")
    $('#zt_address').hide();
  }else{
      //除去运费、运费补贴、计算总价
      $('#freight').text('¥0')
      $('.fbt').text('-¥0')
      $('#zj').text("¥<?php echo $cartCountprice; ?>");
      $('#sf').text("¥<?php echo $cartCountprice-\think\Request::instance()->session('user.balance'); ?>");
      preferential("<?php echo $cartCountprice-\think\Request::instance()->session('user.balance'); ?>")


      $('#zt_address').show();
  }
}



function  preferential(sf){
  var yhj = "<?php echo get_table_field(\think\Cookie::get('couponlist_id'),"id","price","CouponList"); ?>"
  if(yhj){
    var dzf =sf-parseInt(yhj)
  }else{
    dzf =sf

    yhj = 0
  }
  dzf = parseFloat(dzf).toFixed(2)


  $('#dzf').text('¥'+dzf)

  if(sf<0){
    var ye = parseFloat("<?php echo \think\Request::instance()->session('user.balance'); ?>")+parseFloat(sf)-parseFloat(yhj)
    ye = ye.toFixed(2)
    $('#sf').text('余额支付'+ye)
    $('#dzf').text('余额支付'+ye)

    $('#paywaytext').text('余额支付')
    $('.paylist').remove();
  }

}

</script>

<?php if(!(empty(config('shop_hours')) || (config('shop_hours') instanceof \think\Collection && config('shop_hours')->isEmpty()))): ?>
<script>
  var time_range = function (beginTime, endTime) {
    var strb = beginTime.split (":");
    if (strb.length != 2) {
      return false;
    }

    var stre = endTime.split (":");
    if (stre.length != 2) {
      return false;
    }

    var b = new Date ();
    var e = new Date ();
    var n = new Date ();

    b.setHours (strb[0]);
    b.setMinutes (strb[1]);
    e.setHours (stre[0]);
    e.setMinutes (stre[1]);

    if (n.getTime () - b.getTime () > 0 && n.getTime () - e.getTime () < 0) {
      return true;
    } else {

      mui.alert("<?php echo config('shop_hours_message'); ?>", '公告');
      $('.mui-popup-buttons').html(' ')
      $('.mui-popup-inner').css('border-radius', '13px')
      return false;
    }
  }

  var shop_hours = "<?php echo config('shop_hours'); ?>";
  var hours_arr = shop_hours.split('-');
  time_range (hours_arr[0], hours_arr[1]);

</script>
<?php endif; if(config('is_rest') == '1'): ?>
<script>
mui.alert("<?php echo config('rest_message'); ?>", '公告');
$('.mui-popup-buttons').html(' ')
$('.mui-popup-inner').css('border-radius', '13px')
</script>
<?php endif; ?>



<script>
  $(function(){
    $('.subsc').click(function(){
      // $.get("<?php echo url('index/clearusersession'); ?>", function(data){
      //   if(data.code == 1){
      //     window.location.href = "http://mp.weixin.qq.com/s/-AzpDTU7eAD24-R5QUP0wg"
      //   }
      // })
      //cookie('goodsmodel_id', $model_id);
      <?php switch(cookie('goodsmodel_id')): case "1":case "2":case "21":case "22":case "3": ?>
            mui.alert("<img src=<?php echo get_cover(config('frankserviceimg'), 'path'); ?> style='width:100%;'>", '长按扫二维码');
        <?php break; endswitch; if(!(empty($contact_qc) || ($contact_qc instanceof \think\Collection && $contact_qc->isEmpty()))): ?>
            mui.alert('<img src="<?php echo $contact_qc; ?>" style="width:100%;">', '长按扫二维码');
      <?php endif; ?>
    })


    $('.endlimit').each(function(){
      var $this = $(this);
      var stime = $this.attr('data-endtime');
      var starttime = new Date(stime.replace(/-/g,"/"))
      setInterval(function () {
        var nowtime = new Date();
        var time = starttime - nowtime;
        if(time > 0){
          var day = parseInt(time / 1000 / 60 / 60 / 24);
          var hour = parseInt(time / 1000 / 60 / 60 % 24);
          var minute = parseInt(time / 1000 / 60 % 60);
          var seconds = parseInt(time / 1000 % 60);
          $this.html("距结束还有:<span style='color:red'>"+ day + "天" + hour + "小时" + minute + "分钟" + seconds + "秒</span>");
        }

      }, 1000);
    })

    $('.hidecartbtn').each(function(){
      var id = $(this).attr('data-id')
      $('.cartbtn'+id).hide();
    })


  })
</script>

 

 <!-- <?php if(empty(\think\Cookie::get('positioninit')) || (\think\Cookie::get('positioninit') instanceof \think\Collection && \think\Cookie::get('positioninit')->isEmpty())): ?>
 <script type="text/javascript" src="https://3gimg.qq.com/lightmap/components/geolocation/geolocation.min.js"></script>
 <script>
   $(function(){
    var geolocation = new qq.maps.Geolocation("QQ6BZ-24HC6-ZAXSZ-MTZAU-5MU2J-HEFEH", "鲜果屋");
     geolocation.getIpLocation(showPosition, showErr)

   })

   function showPosition(position) {
     console.log(1111);
     $.getJSON("<?php echo url('index/cart/changecookie'); ?>", {name: 'positioninit', 'val': position.lat+','+position.lng}, function(json, textStatus) {});
  };
   function showErr() {
     console.log('定位失败');
   };
 </script>
 <?php endif; ?> -->

</body>
</html>
